<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑组合</title>
    <style>
        .two-part-label{
            width: 300px !important;
        }
    </style>
</head>
<body>
<script type="text/html" id="form">
    <div class="mainBox">
        <div class="main-container">
            <blockquote class="layui-elem-quote">基础信息</blockquote>
            <input type="hidden" name="id" value="{{d.id}}">
            <div class="layui-form-item">
                <label class="layui-form-label" title="关联字段">
                    <text title="必填项" style="color:red;">*</text>
                    关联字段</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="content_id"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"content","material_game_id":"{{d.material_game_id}}"}'
                         data-valueField="id"
                         data-radio="true"
                         data-layVerify="required"
                         data-textField="name"
                         data-placeholder="请选择关联字段"
                         data-selected="{{d.content_id}}"
                    ></div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="关联图鉴组合">
                    <text title="必填项" style="color:red;">*</text>
                    关联图鉴组合</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="material_group_id"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"group","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-layVerify="required"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择关联图鉴组合"
                         data-selected="{{d.material_group_id}}"
                    ></div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    级别</label>
                <div class="layui-input-block">
                    <input type="number" name="label" value="{{d.label}}" lay-verify="required" autocomplete="off" placeholder="请输入级别"
                           class="layui-input">
                </div>
            </div>
            <blockquote class="layui-elem-quote">特殊材料设置</blockquote>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[0]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>0?d.special[0]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[0]" value="{{ d.special.length>0?d.special[0]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[1]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>1?d.special[1]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[1]" value="{{ d.special.length>1?d.special[1]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[2]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>2?d.special[2]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[2]" value="{{ d.special.length>2?d.special[2]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[3]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>3?d.special[3]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[3]" value="{{ d.special.length>3?d.special[3]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[4]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>4?d.special[4]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[4]" value="{{ d.special.length>4?d.special[4]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[5]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>5?d.special[5]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[5]" value="{{ d.special.length>5?d.special[5]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[6]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>6?d.special[6]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[6]" value="{{ d.special.length>6?d.special[6]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择特殊材料">
                    特殊材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="special_id[7]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"special","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择特殊材料"
                         data-selected="{{ d.special.length>7?d.special[7]['material_unit']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="special_number[7]" value="{{ d.special.length>7?d.special[7]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <blockquote class="layui-elem-quote">普通材料设置</blockquote>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[0]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>0?d.material[0]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[0]" value="{{ d.material.length>0?d.material[0]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[1]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>1?d.material[1]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[1]" value="{{ d.material.length>1?d.material[1]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[2]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>2?d.material[2]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[2]"  value="{{ d.material.length>2?d.material[2]['number']:''}}" autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[3]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>3?d.material[3]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[3]" value="{{ d.material.length>3?d.material[3]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[4]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>4?d.material[4]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[4]" value="{{ d.material.length>4?d.material[4]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[5]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>5?d.material[5]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[5]" value="{{ d.material.length>5?d.material[5]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[6]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>6?d.material[6]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[6]" value="{{ d.material.length>6?d.material[6]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="请选择普通材料">
                    普通材料</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="material_id[7]"
                         data-sourceType="route"
                         data-source="/admin.material.style/relation"
                         data-params='{"type":"material","material_game_id":"{{d.material_game_id}}"}'
                         data-radio="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择普通材料"
                         data-selected="{{ d.material.length>7?d.material[7]['material_id']:''}}"
                    ></div>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="material_number[7]" value="{{ d.material.length>7?d.material[7]['number']:''}}"  autocomplete="off" placeholder="请输入数量"
                           class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'],function(){
        let form = layui.form;
        let $ = layui.jquery;

        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }

        //获取数据，渲染到对应的节点上
        facade.ajax({
            route: "/admin.material.data/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
            }
        });
        layui.form.on('submit(add)', function (data) {
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.material.data/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>